Attr__ Crash

I wanted to write a general function to return a string value of an attribute, but rtf markup for Text and yyyy-MM-dd for dates.

I found you may only use an Attr__ variable once. Accessing it again crashes DOORS.

Yeah, I know it is an internal type and shouldn't be used...
I could pass the Object/Module and the AttributeName separatly but it requires more functions or redundant arguments.

Anyone* know what's going on?
 

string AttributeValue(Attr__ oAttr)
{
//     string sTypeBefore = type(oAttr) // Uncomment to Cause Crash
 
        string sValue = oAttr ""
        string sTypeAfter = type(oAttr)
        
//      string sValueAgain = oAttr "" // Uncomment to Cause Crash
        
        return(sValue)
}
 
Module m = current()
print(AttributeValue(m."Prefix"))

 

 

  • :)

 

 


SystemAdmin - Tue Jan 08 10:42:13 EST 2013

Re: Attr__ Crash
SystemAdmin - Tue Jan 08 10:47:03 EST 2013

string AttributeValue(Attr__ oAttr)
{
    string sValue = ""
 
        string sType = type(oAttr)
 
        if(sType == "Date") {
                Date oDate = oAttr
                if(!null(oDate)) {
                        sValue = stringOf(dateAndTime(oDate), userLocale(), "yyyy-MM-dd")
                }
        } else if(sType == "Text") {
                sValue = richTextWithOle(oAttr)
        } else {
                sValue = oAttr ""
        }
        return(sValue)
}

Re: Attr__ Crash
SystemAdmin - Tue Jan 08 13:35:30 EST 2013

SystemAdmin - Tue Jan 08 10:47:03 EST 2013

string AttributeValue(Attr__ oAttr)
{
    string sValue = ""
 
        string sType = type(oAttr)
 
        if(sType == "Date") {
                Date oDate = oAttr
                if(!null(oDate)) {
                        sValue = stringOf(dateAndTime(oDate), userLocale(), "yyyy-MM-dd")
                }
        } else if(sType == "Text") {
                sValue = richTextWithOle(oAttr)
        } else {
                sValue = oAttr ""
        }
        return(sValue)
}

Just stumbled on this post saying that the Attr__ object it auto deallocated by assignment.
Guess it is also freed by the type(Attr__) function too.